package cn.lx;

import java.util.Vector;

/**
 * @author lixin
 * @Classname Concreterator
 * @Description TODO
 * @Date 2019/10/8 下午4:04
 */
public class Concreterator implements Iterator {
    private Vector vector = new Vector();
    // 定义当前游标
    public int cureor = 0;

    @SuppressWarnings("unchecked")
    public Concreterator(Vector _vector) {
        this.vector = _vector;
    }

    public boolean hasNext() {
        if (this.cureor == this.vector.size()) {
            return false;
        } else {
            return true;
        }


    }

    public Object next() {
        Object result = null;
        if (this.hasNext()) {
            result = this.vector.get(this.cureor++);
        } else {
            result = null;
        }
        return result;
    }


    public boolean remove() {
        this.vector.remove(this.cureor);
        return true;
    }
}
